package com.team11.server.controller.student;

import com.team11.server.pojo.student.StudentHomeworkTask;
import com.team11.server.service.student.StudentHomeworkServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author DuKang
 * @Date 2021/7/12 9:39
 * @Desc:
 * @Version: 1.0
 */
@RestController
@CrossOrigin
@RequestMapping("/student")
@Api(tags = "学生接口")
public class StudentHomeworkController {
    @Resource
    private StudentHomeworkServiceImpl studentHomeworkService;

    @GetMapping("/HomeworkList/{sNumber}")
    @ApiOperation(value = "根据作业状态获取学生作业表")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "学生学号",name = "sNumber"),
            @ApiImplicitParam(value = "作业状态",name = "status"),
            @ApiImplicitParam(value = "发布时间",name = "hSetime"),
            @ApiImplicitParam(value = "项目名称",name = "kcName"),
            @ApiImplicitParam(value = "作业主题",name = "hTitle"),
            @ApiImplicitParam(value = "作业类型",name = "hType"),
            @ApiImplicitParam(value = "实训老师",name = "tName"),
            @ApiImplicitParam(value = "结束时间",name = "hStoptime")
    })
    public Object getHomeworkList(@PathVariable String sNumber, Integer status,String hSetime, String kcName,
                                   String hTitle, Integer hType, String tName, String hStoptime){
        return studentHomeworkService.getHomeworkList(sNumber, status,hSetime, kcName, hTitle, hType, tName, hStoptime);
    }
    @GetMapping("/HomeworkTask/{hId}")
    @ApiOperation(value = "根据作业id获取作业任务")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "作业id",name = "hId")
    })
    public StudentHomeworkTask getHomeworkTask(@PathVariable Integer hId){
        return studentHomeworkService.getHomeworkTask(hId);
    }

    @GetMapping("/TeacherReply")
    @ApiOperation(value = "获取老师批复")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "作业id",name = "hId"),
            @ApiImplicitParam(value = "学生学号",name = "sNumber")
    })
    public Object getTeacherReply(Integer hId,String sNumber){
        return studentHomeworkService.getTeacherReply(hId,sNumber);
    }
    @PutMapping("/updateHomeworkAnswer")
    @ApiOperation(value = "提交学生答案")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "学生学号",name = "sNumber"),
            @ApiImplicitParam(value = "作业id",name = "hId"),
            @ApiImplicitParam(value = "学生答案",name = "answer"),

    })
    public Object updateHomeworkAnswer(String sNumber,Integer hId,String answer,
                                       MultipartFile[] files,
                                       HttpServletRequest request){
        return studentHomeworkService.updateAnswer(sNumber,hId,answer,files,request);
    }
    @GetMapping("/getHomeworkAnswer")
    @ApiOperation(value = "获取学生答案")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "学生学号",name = "sNumber"),
            @ApiImplicitParam(value = "作业id",name = "hId")
    })
    public Object getHomeworkAnswer(String sNumber,Integer hId){
        return studentHomeworkService.getAnswer(sNumber, hId);
    }
}
